package win.smartown.kotlin.grammar

/**
 * Created by smartown on 2017/6/4.
 *
 * when
 */

fun main(args: Array<String>) {
    describe(1)
    describe("Hello")
    describe(1000L)
    describe(2)
    describe("other")
}

fun describe(obj: Any): Unit {
    val desc = when (obj) {
        1 -> "One"
        "Hello" -> "Greeting"
        is Long -> "Long"
        !is String -> "Not a string"
        else -> "Unknown"
    }
    println("$obj -> $desc")
}